﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Text;

namespace ConsoleApp2.Modals.Entity
{
    public class DbInitializer:DropCreateDatabaseIfModelChanges<Admin4000DbContext>
    {
        protected override void Seed(Admin4000DbContext context)
        {
            var brand1 = new Brands()
            {
                BrandName = "苹果"
            };

            var brand2 = new Brands()
            {
                BrandName = "香蕉"
            };

            context.Brands.Add(brand1);
            context.Brands.Add(brand2);
            context.SaveChanges();

            var product1 = new Product()
            {
                ProductName = "苹果x",
                ShortDesc = "好用的苹果",
                DetailsDesc = "苹果是由乔布斯创立的一家科技公司",
                BrandId = brand1.Id
            };

            context.Products.Add(product1);
            context.SaveChanges();

            base.Seed(context);
        }

    }
}
